package io.renren.modules.sp.controller.front;

import io.renren.common.utils.Result;
import io.renren.modules.sp.service.SpBaseMatchItemGoupRefService;
import io.renren.modules.sys.entity.SysDictDataEntity;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
* 赛项与组别的关系
*
* @author whc 15953295779@126.com
* @since 3.0 2024-03-08
*/
@RestController
@RequestMapping("front/spbasematchitemgoupref")
@Api(tags="赛项与组别的关系")
public class FrontGoupController {
    @Autowired
    private SpBaseMatchItemGoupRefService spBaseMatchItemGoupRefService;

    /**
     * 组别查询
     * 1、存在 sp_match_item_goup_ref 这个表中的关系，直接通过关联关系查询
     * 2、不存在上表的，只显示小学、初中、高中
     * @param id 赛项ID
     * @return
     */
    @GetMapping("queryGroup")
    public Result<List<SysDictDataEntity>> queryGroup(@RequestParam Long id) {
        List<SysDictDataEntity> list = spBaseMatchItemGoupRefService.queryGroup(id);
        if (list.size() == 0) {
            SysDictDataEntity dictData1 = new SysDictDataEntity();
            dictData1.setId(100301L);
            dictData1.setDictTypeId(100300L);
            dictData1.setDictLabel("小学组");
            list.add(dictData1);
            SysDictDataEntity dictData2 = new SysDictDataEntity();
            dictData2.setId(100302L);
            dictData2.setDictTypeId(100300L);
            dictData2.setDictLabel("初中组");
            list.add(dictData2);
            SysDictDataEntity dictData3 = new SysDictDataEntity();
            dictData3.setId(100303L);
            dictData3.setDictTypeId(100300L);
            dictData3.setDictLabel("高中组");
            list.add(dictData3);
        }
        return new Result<List<SysDictDataEntity>>().ok(list);
    }


}